//  decorator
//  是在声明阶段实现类与类成员注解的一种语法


function log(target) {
    const desc = Object.getOwnPropertyDescriptors(target.prototype)

    for (const key of Object.keys(desc)) {
        if (key === 'constructor') {
            continue;
        }

        const func = desc[key].value;

        if ('function' === typeof func) {
            Object.defineProperty(target.prototype, key, {
                value(...args) {
                    console.log('before');
                    const ret = func.apply(this, args);
                    console.log('after');

                    return ret;
                }
            })
        }
    }
}

function readOnly(target, key, descriptor) {
    descriptor.writable = false;
}

@log
class Numberic {


    @readOnly PI = 3.1415926;

    add(...nums) {
        return nums.reduce((p, n) => (p + n), 0);
    }
}


var numberic = new Numberic();
const sum = numberic.add(1, 2, 3, 4, 5);
// console.log(sum, " =======sum======");

numberic.PI="333";


import React from 'react';
import ReactDom from 'react-dom';
import App from './src/App';

ReactDom.render(<App />, document.getElementById('app'));
